<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>


<!-- 2、输入月份，显示当月的天数（使用case 穿透简化代码）
        1-12 -->

    <script>
        // var num=2;
        var num = +prompt('请输入您想查询的月份');
        switch(num){
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                alert(num +'月份有31天');
                break
            case 4:
            case 6:
            case 9:
            case 11:
                alert(num + '月份有30天')
                break
            case 2:
                alert(num + '月份有28天')
                break
            default:
                alert('请输入1~12的数字')
        }
    </script>

<!-- ------------------------------------------------------------- -->

</body>
</html>